bank_list=[
    {'name':'yezhiyu','password':'12345','rest':2130},
    {'name':'kamu','password':'88888','rest':550}
]
user_list=[]

def bank_origin():
    print('=' * 20, '银行自动存取款机', '=' * 20)
    print('|{:<25}|\n|{:<25}|\n|{:<25}|'.format('1.登陆','2.注册','3.退出'))

def bank_regist():
    user_new={}
    user_new['name'] = input('注册新的用户名')
    user_new['password'] = input('您的新密码')
    user_new['rest'] = 0
    bank_list.append(user_new)

def login_bank():
    print('='*20,'输入账户密码','='*20)
    name1 = input('请输入账户名：')
    password1= input('请输入账户密码：')
    result=0
    global user_list
    for user_dict in bank_list:
        if user_dict['name']==name1 and user_dict['password']==password1:
            result=1
            user_list.append(user_dict)
        elif user_dict['name']==name1 and user_dict['password']!=password1:
            result=2
    if result==1:
        print('登陆成功，即将进入用户界面')
        bank_info()
    elif result==2:
        print('存在该账户，但密码输入错误')
        if input('是否重新输入账户密码 y/n')=='y':
            login_bank()
    else:
        print('\n\n不存在该账户，即将回到初始页面')

def bank_rest():
    print('-'*10,'您账户当前的余额为{}元'.format(user_list[0]['rest']))

def bank_add():
    global user_list
    money=int(input('请输入存款额'))
    if money< 0:
        print('请存入正整数的取款额，不存款请输入0')
        bank_add()
    else:
        print('存款成功')
        user_list[0]['rest']+=money

def bank_take():
    global user_list
    money=int(input('请输入取款额'))
    if money<0:
        print('-'*10,'请存入正整数的取款额')
        bank_take()
    elif money>user_list[0]['rest']:
        print('-'*10,'余额不足，请重新输入取款额/n不取款请输入0')
        bank_take()
    else:
        print('-'*10,'取款成功，请当面点清','-'*10)
        user_list[0]['rest']-=money

def bank_info():
    print('=' * 22, '您的账户信息', '=' * 21)
    print('|{:<24}|\n|{:<25}|\n|{:<25}|\n|{:<25}|'.format('1.查询余额', '2.存款', '3.取款','4.退出'))
    while True:
        key2=input('继续操作序号')
        if key2=='1':
            bank_rest()
            bank_info()
        if key2=='2':
            bank_add()
            bank_info()
        if key2=='3':
            bank_take()
            bank_info()
        if key2=='4':
            bank_origin()
        else:
            print('-'*10,'请输入正确的序号')

while True:
    bank_origin()
    key=input('选择操作序号')
    if key=='1':
        login_bank()
    if key=='2':
        bank_regist()
    if key=='3':
        print('感谢您的使用，请带好随身物品，再见')
        break
    else:
        print('-'*10,'请输入正确的序号')
